Change in openvpn[master]: io_work: pass event_arg object to event handler in case of socket event
A message that is not in the archive (sent off-list or not yet received): gerrit.1727098847000.I7ebf0d4fb2a23278e16003b2e35598178155d658@...2715...
Attention is currently required from: flichtenheld, ordex, plaisthos.
Hello plaisthos, flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/760?usp=email
to review the following change.
Change subject: io_work: pass event_arg object to event handler in case of socket event
......................................................................
io_work: pass event_arg object to event handler in case of socket event
In order to allow the code to work with multiple listening sockets it is essential to allow the generic multi_io event handler to distinguish between the various socket objects.
This can be achieved by passing an event_arg object that contains a pointer to the link_socket.
This code path is used on clients as well as UDP servers.
---
M src/openvpn/event.h
M src/openvpn/forward.c
M src/openvpn/mtcp.c
3 files changed, 30 insertions(+), 5 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/60/760/1
src/openvpn/event.h +6 -0
@@ -82,6 +82,12 @@#define EVENT_METHOD_US_TIMEOUT (1<<0)#define EVENT_METHOD_FAST (1<<1) +/* +* The following constant is used as boundary between integer value +* and real addresses when passing arguments to event handlers as (void *) +*/ +#define MULTI_N ((void *)16)/* upper bound on MTCP_x */ +#ifdef _WIN32typedef const struct rw_handle *event_t ;
src/openvpn/forward.c +23 -2
@@ -2168,7 +2168,8 @@/* * Configure event wait based on socket, tuntap flags. */ -socket_set (c->c2.link_socket, c->c2.event_set, socket, (void *)&socket_shift,NULL ); +socket_set (c->c2.link_socket, c->c2.event_set, socket, + &c->c2.link_socket->ev_arg,NULL );tun_set (c->c1.tuntap, c->c2.event_set, tuntap, (void *)tun_shift,NULL );#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD )if (socket &EVENT_READ && c->c2.did_open_tun)
@@ -2231,7 +2232,27 @@for (i =0 ; i < status; ++i) {const struct event_set_return *e = &esr[i]; - c->c2.event_set_status |= ((e->rwflags &3 ) << (uintptr_t )e->arg); +uintptr_t shift; + +if (e->arg >=MULTI_N ) + { +struct event_arg *ev_arg = (struct event_arg *)e->arg; +if (ev_arg->type !=EVENT_ARG_LINK_SOCKET ) + { + c->c2.event_set_status =ES_ERROR ; +msg (D_LINK_ERRORS , +"io_work: non socket event delivered" ); +return ; + } + + shift = socket_shift; + } +else + { + shift = (uintptr_t )e->arg; + } + + c->c2.event_set_status |= ((e->rwflags &3 ) << shift); } }else if (status ==0 )
src/openvpn/mtcp.c +1 -3
@@ -61,8 +61,6 @@#define MTCP_FILE_CLOSE_WRITE ((void *)5)#define MTCP_DCO ((void *)6) -#define MTCP_N ((void *)16)/* upper bound on MTCP_x */ -struct ta_iow_flags {unsigned int flags;
@@ -695,7 +693,7 @@struct event_arg *ev_arg = (struct event_arg *)e->arg;/* incoming data for instance or listening socket? */ -if (e->arg >=MTCP_N ) +if (e->arg >=MULTI_N ) {switch (ev_arg->type) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/760?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7ebf0d4fb2a23278e16003b2e35598178155d658
Gerrit-Change-Number: 760
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld, plaisthos.
Hello flichtenheld, ordex, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/760?usp=email
to look at the new patch set (#2).
Change subject: io_work: pass event_arg object to event handler in case of socket event
......................................................................
io_work: pass event_arg object to event handler in case of socket event
In order to allow the code to work with multiple listening sockets it is essential to allow the generic multi_io event handler to distinguish between the various socket objects.
This can be achieved by passing an event_arg object that contains a pointer to the link_socket.
This code path is used on clients as well as UDP servers.
---
M src/openvpn/event.h
M src/openvpn/forward.c
M src/openvpn/mtcp.c
3 files changed, 30 insertions(+), 5 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/60/760/2
src/openvpn/event.h +6 -0
@@ -82,6 +82,12 @@#define EVENT_METHOD_US_TIMEOUT (1<<0)#define EVENT_METHOD_FAST (1<<1) +/* +* The following constant is used as boundary between integer value +* and real addresses when passing arguments to event handlers as (void *) +*/ +#define MULTI_N ((void *)16)/* upper bound on MTCP_x */ +#ifdef _WIN32typedef const struct rw_handle *event_t ;
src/openvpn/forward.c +23 -2
@@ -2183,7 +2183,8 @@/* * Configure event wait based on socket, tuntap flags. */ -socket_set (c->c2.link_socket, c->c2.event_set, socket, (void *)socket_shift,NULL ); +socket_set (c->c2.link_socket, c->c2.event_set, socket, + &c->c2.link_socket->ev_arg,NULL );tun_set (c->c1.tuntap, c->c2.event_set, tuntap, (void *)tun_shift,NULL );#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD )if (socket &EVENT_READ && c->c2.did_open_tun)
@@ -2246,7 +2247,27 @@for (i =0 ; i < status; ++i) {const struct event_set_return *e = &esr[i]; - c->c2.event_set_status |= ((e->rwflags &3 ) << (uintptr_t )e->arg); +uintptr_t shift; + +if (e->arg >=MULTI_N ) + { +struct event_arg *ev_arg = (struct event_arg *)e->arg; +if (ev_arg->type !=EVENT_ARG_LINK_SOCKET ) + { + c->c2.event_set_status =ES_ERROR ; +msg (D_LINK_ERRORS , +"io_work: non socket event delivered" ); +return ; + } + + shift = socket_shift; + } +else + { + shift = (uintptr_t )e->arg; + } + + c->c2.event_set_status |= ((e->rwflags &3 ) << shift); } }else if (status ==0 )
src/openvpn/mtcp.c +1 -3
@@ -61,8 +61,6 @@#define MTCP_FILE_CLOSE_WRITE ((void *)5)#define MTCP_DCO ((void *)6) -#define MTCP_N ((void *)16)/* upper bound on MTCP_x */ -struct ta_iow_flags {unsigned int flags;
@@ -695,7 +693,7 @@struct event_arg *ev_arg = (struct event_arg *)e->arg;/* incoming data for instance or listening socket? */ -if (e->arg >=MTCP_N ) +if (e->arg >=MULTI_N ) {switch (ev_arg->type) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/760?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7ebf0d4fb2a23278e16003b2e35598178155d658
Gerrit-Change-Number: 760
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: its_Giaan, ordex, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/760?usp=email )
Change subject: io_work: pass event_arg object to event handler in case of socket event
......................................................................
Patch Set 3: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/760?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7ebf0d4fb2a23278e16003b2e35598178155d658
Gerrit-Change-Number: 760
Gerrit-PatchSet: 3
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Fri, 11 Oct 2024 12:34:17 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: its_Giaan, plaisthos.
Hello flichtenheld, ordex, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/760?usp=email
to look at the new patch set (#4).
The change is no longer submittable: checks~ChecksSubmitRule is unsatisfied now.
Change subject: io_work: pass event_arg object to event handler in case of socket event
......................................................................
io_work: pass event_arg object to event handler in case of socket event
In order to allow the code to work with multiple listening sockets it is essential to allow the generic multi_io event handler to distinguish between the various socket objects.
This can be achieved by passing an event_arg object that contains a pointer to the link_socket.
This code path is used on clients as well as UDP servers.
---
M src/openvpn/event.h
M src/openvpn/forward.c
M src/openvpn/mtcp.c
3 files changed, 30 insertions(+), 5 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/60/760/4
src/openvpn/event.h +6 -0
@@ -82,6 +82,12 @@#define EVENT_METHOD_US_TIMEOUT (1<<0)#define EVENT_METHOD_FAST (1<<1) +/* +* The following constant is used as boundary between integer value +* and real addresses when passing arguments to event handlers as (void *) +*/ +#define MULTI_N ((void *)16)/* upper bound on MTCP_x */ +#ifdef _WIN32typedef const struct rw_handle *event_t ;
src/openvpn/forward.c +23 -2
@@ -2183,7 +2183,8 @@/* * Configure event wait based on socket, tuntap flags. */ -socket_set (c->c2.link_socket, c->c2.event_set, socket, (void *)socket_shift,NULL ); +socket_set (c->c2.link_socket, c->c2.event_set, socket, + &c->c2.link_socket->ev_arg,NULL );tun_set (c->c1.tuntap, c->c2.event_set, tuntap, (void *)tun_shift,NULL );#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD )if (socket &EVENT_READ && c->c2.did_open_tun)
@@ -2246,7 +2247,27 @@for (i =0 ; i < status; ++i) {const struct event_set_return *e = &esr[i]; - c->c2.event_set_status |= ((e->rwflags &3 ) << (uintptr_t )e->arg); +uintptr_t shift; + +if (e->arg >=MULTI_N ) + { +struct event_arg *ev_arg = (struct event_arg *)e->arg; +if (ev_arg->type !=EVENT_ARG_LINK_SOCKET ) + { + c->c2.event_set_status =ES_ERROR ; +msg (D_LINK_ERRORS , +"io_work: non socket event delivered" ); +return ; + } + + shift = socket_shift; + } +else + { + shift = (uintptr_t )e->arg; + } + + c->c2.event_set_status |= ((e->rwflags &3 ) << shift); } }else if (status ==0 )
src/openvpn/mtcp.c +1 -3
@@ -60,8 +60,6 @@#define MTCP_FILE_CLOSE_WRITE ((void *)5)#define MTCP_DCO ((void *)6) -#define MTCP_N ((void *)16)/* upper bound on MTCP_x */ -struct ta_iow_flags {unsigned int flags;
@@ -693,7 +691,7 @@struct event_set_return *e = &mtcp->esr[i];/* incoming data for instance or listening socket? */ -if (e->arg >=MTCP_N ) +if (e->arg >=MULTI_N ) {struct event_arg *ev_arg = (struct event_arg *)e->arg; switch (ev_arg->type)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/760?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7ebf0d4fb2a23278e16003b2e35598178155d658
Gerrit-Change-Number: 760
Gerrit-PatchSet: 4
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-MessageType: newpatchset
PATCH v4 1/1 io_work: pass event_arg object to event handler in case of socket event
In reply to a message not in the archiveFrom: Antonio Quartulli <[email protected]...>
In order to allow the code to work with multiple listening sockets it is essential to allow the generic multi_io event handler to distinguish between the various socket objects.
This can be achieved by passing an event_arg object that contains a pointer to the link_socket.
This code path is used on clients as well as UDP servers.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Manually added Signed-off-by for Giaan
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/760
This mail reflects revision 4 of this Change.
Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>
src/openvpn/event.h +6 -0
@@ -82,6 +82,12 @@#define EVENT_METHOD_US_TIMEOUT (1<<0)#define EVENT_METHOD_FAST (1<<1) +/* +* The following constant is used as boundary between integer value +* and real addresses when passing arguments to event handlers as (void *) +*/ +#define MULTI_N ((void *)16)/* upper bound on MTCP_x */ +#ifdef _WIN32typedef const struct rw_handle *event_t ;
src/openvpn/forward.c +23 -2
@@ -2183,7 +2183,8 @@/* * Configure event wait based on socket, tuntap flags. */ -socket_set (c->c2.link_socket, c->c2.event_set, socket, (void *)socket_shift,NULL ); +socket_set (c->c2.link_socket, c->c2.event_set, socket, + &c->c2.link_socket->ev_arg,NULL );tun_set (c->c1.tuntap, c->c2.event_set, tuntap, (void *)tun_shift,NULL );#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD )if (socket &EVENT_READ && c->c2.did_open_tun)
@@ -2246,7 +2247,27 @@for (i =0 ; i < status; ++i) {const struct event_set_return *e = &esr[i]; - c->c2.event_set_status |= ((e->rwflags &3 ) << (uintptr_t )e->arg); +uintptr_t shift; + +if (e->arg >=MULTI_N ) + { +struct event_arg *ev_arg = (struct event_arg *)e->arg; +if (ev_arg->type !=EVENT_ARG_LINK_SOCKET ) + { + c->c2.event_set_status =ES_ERROR ; +msg (D_LINK_ERRORS , +"io_work: non socket event delivered" ); +return ; + } + + shift = socket_shift; + } +else + { + shift = (uintptr_t )e->arg; + } + + c->c2.event_set_status |= ((e->rwflags &3 ) << shift); } }else if (status ==0 )
src/openvpn/mtcp.c +1 -3
@@ -60,8 +60,6 @@#define MTCP_FILE_CLOSE_WRITE ((void *)5)#define MTCP_DCO ((void *)6) -#define MTCP_N ((void *)16)/* upper bound on MTCP_x */ -struct ta_iow_flags {unsigned int flags;
@@ -693,7 +691,7 @@struct event_set_return *e = &mtcp->esr[i];/* incoming data for instance or listening socket? */ -if (e->arg >=MTCP_N ) +if (e->arg >=MULTI_N ) {struct event_arg *ev_arg = (struct event_arg *)e->arg; switch (ev_arg->type)
Attention is currently required from: flichtenheld, its_Giaan, ordex, plaisthos.
Hello flichtenheld, ordex, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/760?usp=email
to look at the new patch set (#5).
The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld
The change is no longer submittable: Code-Review and checks~ChecksSubmitRule are unsatisfied now.
Change subject: io_work: pass event_arg object to event handler in case of socket event
......................................................................
io_work: pass event_arg object to event handler in case of socket event
In order to allow the code to work with multiple listening sockets it is essential to allow the generic multi_io event handler to distinguish between the various socket objects.
This can be achieved by passing an event_arg object that contains a pointer to the link_socket.
This code path is used on clients as well as UDP servers.
---
M src/openvpn/event.h
M src/openvpn/forward.c
M src/openvpn/mtcp.c
3 files changed, 30 insertions(+), 5 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/60/760/5
src/openvpn/event.h +6 -0
@@ -82,6 +82,12 @@#define EVENT_METHOD_US_TIMEOUT (1<<0)#define EVENT_METHOD_FAST (1<<1) +/* +* The following constant is used as boundary between integer value +* and real addresses when passing arguments to event handlers as (void *) +*/ +#define MULTI_N ((void *)16)/* upper bound on MTCP_x */ +#ifdef _WIN32typedef const struct rw_handle *event_t ;
src/openvpn/forward.c +23 -2
@@ -2183,7 +2183,8 @@/* * Configure event wait based on socket, tuntap flags. */ -socket_set (c->c2.link_socket, c->c2.event_set, socket, (void *)socket_shift,NULL ); +socket_set (c->c2.link_socket, c->c2.event_set, socket, + &c->c2.link_socket->ev_arg,NULL );tun_set (c->c1.tuntap, c->c2.event_set, tuntap, (void *)tun_shift,NULL );#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD )if (socket &EVENT_READ && c->c2.did_open_tun)
@@ -2246,7 +2247,27 @@for (i =0 ; i < status; ++i) {const struct event_set_return *e = &esr[i]; - c->c2.event_set_status |= ((e->rwflags &3 ) << (uintptr_t )e->arg); +uintptr_t shift; + +if (e->arg >=MULTI_N ) + { +struct event_arg *ev_arg = (struct event_arg *)e->arg; +if (ev_arg->type !=EVENT_ARG_LINK_SOCKET ) + { + c->c2.event_set_status =ES_ERROR ; +msg (D_LINK_ERRORS , +"io_work: non socket event delivered" ); +return ; + } + + shift = socket_shift; + } +else + { + shift = (uintptr_t )e->arg; + } + + c->c2.event_set_status |= ((e->rwflags &3 ) << shift); } }else if (status ==0 )
src/openvpn/mtcp.c +1 -3
@@ -60,8 +60,6 @@#define MTCP_FILE_CLOSE_WRITE ((void *)5)#define MTCP_DCO ((void *)6) -#define MTCP_N ((void *)16)/* upper bound on MTCP_x */ -struct ta_iow_flags {unsigned int flags;
@@ -693,7 +691,7 @@struct event_set_return *e = &mtcp->esr[i];/* incoming data for instance or listening socket? */ -if (e->arg >=MTCP_N ) +if (e->arg >=MULTI_N ) {struct event_arg *ev_arg = (struct event_arg *)e->arg; switch (ev_arg->type)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/760?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7ebf0d4fb2a23278e16003b2e35598178155d658
Gerrit-Change-Number: 760
Gerrit-PatchSet: 5
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: its_Giaan, ordex, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/760?usp=email )
Change subject: io_work: pass event_arg object to event handler in case of socket event
......................................................................
Patch Set 5: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/760?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7ebf0d4fb2a23278e16003b2e35598178155d658
Gerrit-Change-Number: 760
Gerrit-PatchSet: 5
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Thu, 17 Oct 2024 15:38:34 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, its_Giaan, plaisthos.
Hello flichtenheld, ordex, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/760?usp=email
to look at the new patch set (#6).
The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld
The change is no longer submittable: Code-Review and checks~ChecksSubmitRule are unsatisfied now.
Change subject: io_work: pass event_arg object to event handler in case of socket event
......................................................................
io_work: pass event_arg object to event handler in case of socket event
In order to allow the code to work with multiple listening sockets it is essential to allow the generic multi_io event handler to distinguish between the various socket objects.
This can be achieved by passing an event_arg object that contains a pointer to the link_socket.
This code path is used on clients as well as UDP servers.
---
M src/openvpn/event.h
M src/openvpn/forward.c
M src/openvpn/mtcp.c
3 files changed, 37 insertions(+), 4 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/60/760/6
src/openvpn/event.h +6 -0
@@ -82,6 +82,12 @@#define EVENT_METHOD_US_TIMEOUT (1<<0)#define EVENT_METHOD_FAST (1<<1) +/* +* The following constant is used as boundary between integer value +* and real addresses when passing arguments to event handlers as (void *) +*/ +#define MULTI_N ((void *)16)/* upper bound on MTCP_x */ +#ifdef _WIN32typedef const struct rw_handle *event_t ;
src/openvpn/forward.c +23 -2
@@ -2183,7 +2183,8 @@/* * Configure event wait based on socket, tuntap flags. */ -socket_set (c->c2.link_socket, c->c2.event_set, socket, (void *)socket_shift,NULL ); +socket_set (c->c2.link_socket, c->c2.event_set, socket, + &c->c2.link_socket->ev_arg,NULL );tun_set (c->c1.tuntap, c->c2.event_set, tuntap, (void *)tun_shift,NULL );#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD )if (socket &EVENT_READ && c->c2.did_open_tun)
@@ -2246,7 +2247,27 @@for (i =0 ; i < status; ++i) {const struct event_set_return *e = &esr[i]; - c->c2.event_set_status |= ((e->rwflags &3 ) << (uintptr_t )e->arg); +uintptr_t shift; + +if (e->arg >=MULTI_N ) + { +struct event_arg *ev_arg = (struct event_arg *)e->arg; +if (ev_arg->type !=EVENT_ARG_LINK_SOCKET ) + { + c->c2.event_set_status =ES_ERROR ; +msg (D_LINK_ERRORS , +"io_work: non socket event delivered" ); +return ; + } + + shift = socket_shift; + } +else + { + shift = (uintptr_t )e->arg; + } + + c->c2.event_set_status |= ((e->rwflags &3 ) << shift); } }else if (status ==0 )
src/openvpn/mtcp.c +8 -2
@@ -60,7 +60,13 @@#define MTCP_FILE_CLOSE_WRITE ((void *)5)#define MTCP_DCO ((void *)6) -#define MTCP_N ((void *)16)/* upper bound on MTCP_x */ +struct ta_iow_flags +{ +unsigned int flags; +unsigned int ret; +unsigned int tun; +unsigned int sock; +};#ifdef ENABLE_DEBUG static const char *
@@ -686,7 +692,7 @@struct event_set_return *e = &mtcp->esr[i];/* incoming data for instance or listening socket? */ -if (e->arg >=MTCP_N ) +if (e->arg >=MULTI_N ) {struct event_arg *ev_arg = (struct event_arg *)e->arg; switch (ev_arg->type)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/760?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7ebf0d4fb2a23278e16003b2e35598178155d658
Gerrit-Change-Number: 760
Gerrit-PatchSet: 6
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset
PATCH v6 1/1 io_work: pass event_arg object to event handler in case of socket event
In reply to a message not in the archiveFrom: Antonio Quartulli <[email protected]...>
In order to allow the code to work with multiple listening sockets it is essential to allow the generic multi_io event handler to distinguish between the various socket objects.
This can be achieved by passing an event_arg object that contains a pointer to the link_socket.
This code path is used on clients as well as UDP servers.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/760
This mail reflects revision 6 of this Change.
Acked-by according to Gerrit (reflected above):
src/openvpn/event.h +6 -0
@@ -82,6 +82,12 @@#define EVENT_METHOD_US_TIMEOUT (1<<0)#define EVENT_METHOD_FAST (1<<1) +/* +* The following constant is used as boundary between integer value +* and real addresses when passing arguments to event handlers as (void *) +*/ +#define MULTI_N ((void *)16)/* upper bound on MTCP_x */ +#ifdef _WIN32typedef const struct rw_handle *event_t ;
src/openvpn/forward.c +23 -2
@@ -2183,7 +2183,8 @@/* * Configure event wait based on socket, tuntap flags. */ -socket_set (c->c2.link_socket, c->c2.event_set, socket, (void *)socket_shift,NULL ); +socket_set (c->c2.link_socket, c->c2.event_set, socket, + &c->c2.link_socket->ev_arg,NULL );tun_set (c->c1.tuntap, c->c2.event_set, tuntap, (void *)tun_shift,NULL );#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD )if (socket &EVENT_READ && c->c2.did_open_tun)
@@ -2246,7 +2247,27 @@for (i =0 ; i < status; ++i) {const struct event_set_return *e = &esr[i]; - c->c2.event_set_status |= ((e->rwflags &3 ) << (uintptr_t )e->arg); +uintptr_t shift; + +if (e->arg >=MULTI_N ) + { +struct event_arg *ev_arg = (struct event_arg *)e->arg; +if (ev_arg->type !=EVENT_ARG_LINK_SOCKET ) + { + c->c2.event_set_status =ES_ERROR ; +msg (D_LINK_ERRORS , +"io_work: non socket event delivered" ); +return ; + } + + shift = socket_shift; + } +else + { + shift = (uintptr_t )e->arg; + } + + c->c2.event_set_status |= ((e->rwflags &3 ) << shift); } }else if (status ==0 )
src/openvpn/mtcp.c +8 -2
@@ -60,7 +60,13 @@#define MTCP_FILE_CLOSE_WRITE ((void *)5)#define MTCP_DCO ((void *)6) -#define MTCP_N ((void *)16)/* upper bound on MTCP_x */ +struct ta_iow_flags +{ +unsigned int flags; +unsigned int ret; +unsigned int tun; +unsigned int sock; +};#ifdef ENABLE_DEBUG static const char *
@@ -686,7 +692,7 @@struct event_set_return *e = &mtcp->esr[i];/* incoming data for instance or listening socket? */ -if (e->arg >=MTCP_N ) +if (e->arg >=MULTI_N ) {struct event_arg *ev_arg = (struct event_arg *)e->arg; switch (ev_arg->type)
[Openvpn-devel] [PATCH applied] Re: io_work: pass event_arg object to event handler in case of socket event
Tested on the server testbed (and GHA, for good measure).
The code change looks okayish. "struct ta_iow_flags" is not used yet, but hints at interesting things to come :-)
Your patch has been applied to the master branch.
commit 58612741680994928e67a0e981c91bbffb7a2d20
Author: Antonio Quartulli Date: Wed Oct 23 16:20:30 2024 +0200
io_work: pass event_arg object to event handler in case of socket event
Signed-off-by: Antonio Quartulli <[email protected]...>
Signed-off-by: Gianmarco De Gregori <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg29625.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#7) to the change originally created by its_Giaan. ( http://gerrit.openvpn.net/c/openvpn/+/760?usp=email )
Change subject: io_work: pass event_arg object to event handler in case of socket event
......................................................................
io_work: pass event_arg object to event handler in case of socket event
In order to allow the code to work with multiple listening sockets it is essential to allow the generic multi_io event handler to distinguish between the various socket objects.
This can be achieved by passing an event_arg object that contains a pointer to the link_socket.
This code path is used on clients as well as UDP servers.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg29625.html
---
M src/openvpn/event.h
M src/openvpn/forward.c
M src/openvpn/mtcp.c
3 files changed, 37 insertions(+), 4 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/60/760/7
src/openvpn/event.h +6 -0
@@ -82,6 +82,12 @@#define EVENT_METHOD_US_TIMEOUT (1<<0)#define EVENT_METHOD_FAST (1<<1) +/* +* The following constant is used as boundary between integer value +* and real addresses when passing arguments to event handlers as (void *) +*/ +#define MULTI_N ((void *)16)/* upper bound on MTCP_x */ +#ifdef _WIN32typedef const struct rw_handle *event_t ;
src/openvpn/forward.c +23 -2
@@ -2183,7 +2183,8 @@/* * Configure event wait based on socket, tuntap flags. */ -socket_set (c->c2.link_socket, c->c2.event_set, socket, (void *)socket_shift,NULL ); +socket_set (c->c2.link_socket, c->c2.event_set, socket, + &c->c2.link_socket->ev_arg,NULL );tun_set (c->c1.tuntap, c->c2.event_set, tuntap, (void *)tun_shift,NULL );#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD )if (socket &EVENT_READ && c->c2.did_open_tun)
@@ -2246,7 +2247,27 @@for (i =0 ; i < status; ++i) {const struct event_set_return *e = &esr[i]; - c->c2.event_set_status |= ((e->rwflags &3 ) << (uintptr_t )e->arg); +uintptr_t shift; + +if (e->arg >=MULTI_N ) + { +struct event_arg *ev_arg = (struct event_arg *)e->arg; +if (ev_arg->type !=EVENT_ARG_LINK_SOCKET ) + { + c->c2.event_set_status =ES_ERROR ; +msg (D_LINK_ERRORS , +"io_work: non socket event delivered" ); +return ; + } + + shift = socket_shift; + } +else + { + shift = (uintptr_t )e->arg; + } + + c->c2.event_set_status |= ((e->rwflags &3 ) << shift); } }else if (status ==0 )
src/openvpn/mtcp.c +8 -2
@@ -60,7 +60,13 @@#define MTCP_FILE_CLOSE_WRITE ((void *)5)#define MTCP_DCO ((void *)6) -#define MTCP_N ((void *)16)/* upper bound on MTCP_x */ +struct ta_iow_flags +{ +unsigned int flags; +unsigned int ret; +unsigned int tun; +unsigned int sock; +};#ifdef ENABLE_DEBUG static const char *
@@ -686,7 +692,7 @@struct event_set_return *e = &mtcp->esr[i];/* incoming data for instance or listening socket? */ -if (e->arg >=MTCP_N ) +if (e->arg >=MULTI_N ) {struct event_arg *ev_arg = (struct event_arg *)e->arg; switch (ev_arg->type)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/760?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7ebf0d4fb2a23278e16003b2e35598178155d658
Gerrit-Change-Number: 760
Gerrit-PatchSet: 7
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/760?usp=email )
Change subject: io_work: pass event_arg object to event handler in case of socket event
......................................................................
io_work: pass event_arg object to event handler in case of socket event
In order to allow the code to work with multiple listening sockets it is essential to allow the generic multi_io event handler to distinguish between the various socket objects.
This can be achieved by passing an event_arg object that contains a pointer to the link_socket.
This code path is used on clients as well as UDP servers.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg29625.html
---
M src/openvpn/event.h
M src/openvpn/forward.c
M src/openvpn/mtcp.c
3 files changed, 37 insertions(+), 4 deletions(-)
src/openvpn/event.h +6 -0
@@ -82,6 +82,12 @@#define EVENT_METHOD_US_TIMEOUT (1<<0)#define EVENT_METHOD_FAST (1<<1) +/* +* The following constant is used as boundary between integer value +* and real addresses when passing arguments to event handlers as (void *) +*/ +#define MULTI_N ((void *)16)/* upper bound on MTCP_x */ +#ifdef _WIN32typedef const struct rw_handle *event_t ;
src/openvpn/forward.c +23 -2
@@ -2183,7 +2183,8 @@/* * Configure event wait based on socket, tuntap flags. */ -socket_set (c->c2.link_socket, c->c2.event_set, socket, (void *)socket_shift,NULL ); +socket_set (c->c2.link_socket, c->c2.event_set, socket, + &c->c2.link_socket->ev_arg,NULL );tun_set (c->c1.tuntap, c->c2.event_set, tuntap, (void *)tun_shift,NULL );#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD )if (socket &EVENT_READ && c->c2.did_open_tun)
@@ -2246,7 +2247,27 @@for (i =0 ; i < status; ++i) {const struct event_set_return *e = &esr[i]; - c->c2.event_set_status |= ((e->rwflags &3 ) << (uintptr_t )e->arg); +uintptr_t shift; + +if (e->arg >=MULTI_N ) + { +struct event_arg *ev_arg = (struct event_arg *)e->arg; +if (ev_arg->type !=EVENT_ARG_LINK_SOCKET ) + { + c->c2.event_set_status =ES_ERROR ; +msg (D_LINK_ERRORS , +"io_work: non socket event delivered" ); +return ; + } + + shift = socket_shift; + } +else + { + shift = (uintptr_t )e->arg; + } + + c->c2.event_set_status |= ((e->rwflags &3 ) << shift); } }else if (status ==0 )
src/openvpn/mtcp.c +8 -2
@@ -60,7 +60,13 @@#define MTCP_FILE_CLOSE_WRITE ((void *)5)#define MTCP_DCO ((void *)6) -#define MTCP_N ((void *)16)/* upper bound on MTCP_x */ +struct ta_iow_flags +{ +unsigned int flags; +unsigned int ret; +unsigned int tun; +unsigned int sock; +};#ifdef ENABLE_DEBUG static const char *
@@ -686,7 +692,7 @@struct event_set_return *e = &mtcp->esr[i];/* incoming data for instance or listening socket? */ -if (e->arg >=MTCP_N ) +if (e->arg >=MULTI_N ) {struct event_arg *ev_arg = (struct event_arg *)e->arg; switch (ev_arg->type)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/760?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7ebf0d4fb2a23278e16003b2e35598178155d658
Gerrit-Change-Number: 760
Gerrit-PatchSet: 7
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-MessageType: merged